<template>
  <div class="exception-handle">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="过磅流水" name="first">
        <div class="exception-header weight">
          <el-form :inline="true" :model="queryForm" class="adjustCondition">
            <el-form-item label="过磅时间:">
              <el-date-picker
                class="adjustDate"
                value-format="yyyy-MM-dd HH:mm:ss"
                v-model="dateInput"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item class="exception-keyword" label="关键字:">
              <el-input v-model="queryForm.keyword" placeholder="请输入过磅单编号/往来名称/业务编号查询"></el-input>
            </el-form-item>
            <div class="adjust">
            <el-form-item label="类型:">
              <el-select clearable v-model="queryForm.transProps" placeholder="全部">
                <el-option
                  v-for="item in  $dictUtils.getDictList('transProps')"
                  :key="item.value"
                  :label="item.label"
                  :value="Number(item.value)">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" class="search-btn" @click="getList(
                  page1,
                  orderBy,
                  queryForm.keyword,
                  dateInput,
                  queryForm.transProps
                )">查询</el-button>
              <el-button @click="reset">重置</el-button>
            </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="clear">
          <div class="exception-table-title">
            共<span> {{this.totalCount}} </span>条过磅单，其中已完成<span style="color: #1890FF"> {{this.completedCount}} </span>条，未完成<span
            style="color: #FF3E3E"> {{this.noCompletedCount}} </span>条
          </div>
          <section class="right-but" style="display:flex;">
            <el-button type="text" style="margin-right:-13px;cursor:pointer;"
                       @click="refreshList"
            >
              <img style="width:44px;height:36px;" src="~@/assets/img/shuaxin.png">
            </el-button>
            <PopoverBut class="selectBut" ref="popoverBut" :checkedProps="checkedProps" style="" :options="options"
                        @getCheckeds="handlerCloumn"></PopoverBut>

          </section>
        </div>
        <div class="exception-table">
          <div class="exception-table-content">
            <el-table
              :data="tableData"
              stripe
              border
              v-loading="loading"
              class="adjustAppendTable"
              style="width: 100%">
              <el-table-column type="expand" width="30px">
                <template slot-scope="scope">
                  <el-form class="append-form" ref="form" :model="scope.row">
                    <el-row class="row-more">
                      <el-form-item label="扣水:">
                        <p>{{scope.row.deductWeightWater | thousandSep}}</p>
                      </el-form-item>
                      <el-form-item label="业务编号:">
                        <p v-if="scope.row.business && scope.row.business.codes">{{scope.row.business.codes | noValue}}</p>
                      </el-form-item>
                      <el-form-item label="创建时间:">
                        <p>{{scope.row.createDate | noValue}}</p>
                      </el-form-item>
                    </el-row>
                    <el-row class="row-more">
                      <el-form-item label="扣杂:">
                        <p>{{scope.row.deductWeightImpurity | thousandSep}}</p>
                      </el-form-item>
                      <el-form-item label="磅单打印次数:">
                        <p>{{scope.row.weightListPrintTimes | thousandSep}}</p>
                      </el-form-item>
                      <el-form-item label="上次操作人:">
                        <p v-if="scope.row.updateBy && scope.row.updateBy.loginName">
                           {{scope.row.updateBy.loginName | noValue}}
                        </p>
                        <p v-else>--</p>
                      </el-form-item>
                    </el-row>
                    <el-row class="row-more">
                      <el-form-item label="路耗:">
                        <p>{{scope.row.lossWeight | thousandSep}}</p>
                      </el-form-item>
                      <el-form-item label="原发时间:">
                        <p>{{scope.row.originalDate | noValue}}</p>
                      </el-form-item>
                      <el-form-item label="上次操作时间:">
                        <p>{{scope.row.updateDate | noValue}}</p>
                      </el-form-item>
                    </el-row>
                    <el-row class="row-more">
                      <el-form-item label="其他扣重:">
                        <p>{{scope.row.deductWeight | thousandSep}}</p>
                      </el-form-item>
                      <el-form-item label="创建人:">
                        <p v-if="scope.row.createBy && scope.row.createBy.loginName">
                             {{scope.row.createBy.loginName | noValue}}
                        </p>
                        <p v-else>--</p>
                      </el-form-item>
                      <el-form-item></el-form-item>
                    </el-row>
                  </el-form>
                </template>
              </el-table-column>
              <el-table-column type="index" label="序号" width="40">
                <template slot-scope="scope">
          <span>{{
            (page1.pageNo - 1) * page1.pageSize + scope.$index + 1
          }}</span>
                </template>
              </el-table-column>
              <el-table-column label="过磅编号" prop="weightCode" min-width="180">
                <template slot-scope="scope">
                  <el-link :underline="false" type="primary" @click="viewDetail(scope.row)">
                    <p>{{$dictUtils.getDictLabel("processType", scope.row.business.processType, "")}}</p>
                    <p>{{scope.row.weightCode}}</p>
                  </el-link>
                </template>
              </el-table-column>
              <el-table-column label="客户/供应商名称" prop="business.companyName" min-width="200">
                <template slot-scope="scope">
                  <div>
                    <p v-if="scope.row.business && scope.row.business.companyName">{{scope.row.business.companyName | noValue}}</p>
                    <p v-else>--</p>
                  </div>
                  <div>
                    <p v-if="scope.row.product && scope.row.product.name">({{scope.row.product.name | noValue}})</p>
                    <p v-else>--</p>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="车牌号" prop="transport.truckNumber" min-width="120"></el-table-column>
<!--              <el-table-column label="货物" prop="product.name" min-width="140"></el-table-column>-->

              <el-table-column label="原发" prop="originalWeight" min-width="80">
                <template slot-scope="scope">
                  {{scope.row.originalWeight | thousandSep}}
                </template>
              </el-table-column>
              <el-table-column label="毛重" prop="weightGross" min-width="80">
                <template slot-scope="scope">
                  {{scope.row.weightGross | thousandSep}}
                </template>
              </el-table-column>
              <el-table-column label="皮重" prop="weightTare" min-width="80">
                <template slot-scope="scope">
                  {{scope.row.weightTare | thousandSep}}
                </template>
              </el-table-column>
              <el-table-column label="净重" prop="netWeight" min-width="80">
                <template slot-scope="scope">
                  {{scope.row.netWeight | thousandSep}}
                </template>
              </el-table-column>
<!--              <el-table-column label="过磅类型" prop="business.processType" min-width="110">-->
<!--                <template slot-scope="scope">-->
<!--                  {{$dictUtils.getDictLabel("processType", scope.row.business.processType, "")}}-->
<!--                </template>-->
<!--              </el-table-column>-->
              <el-table-column label="毛重时间" prop="gross.weightTime" width="140">
                <template slot-scope="scope">
                  <span v-if="scope.row.gross && scope.row.gross.weightTime">{{scope.row.gross.weightTime | noValue}}</span>
                  <span v-else>--</span>
                </template>
              </el-table-column>
              <el-table-column label="皮重时间" prop="tare.weightTime" width="140">
                <template slot-scope="scope">
                  <span v-if="scope.row.tare && scope.row.tare.weightTime">{{scope.row.tare.weightTime | noValue}}</span>
                  <span v-else>--</span>
                </template>
              </el-table-column>
              <el-table-column label="状态" prop="transport.state" width="160">
                <template slot-scope="scope">
                  <div class="state" :class="{
                  empty: scope.row.transport.state === 0,
                  process: scope.row.transport.state === 1,
                  invalid: scope.row.transport.state === 2 || scope.row.transport.state === 3,
                  normal: scope.row.transport.state === 100 || scope.row.transport.state === 101
                  }">
                    <span></span>{{$dictUtils.getDictLabel("transState", scope.row.transport.state, "")}}</div>
                </template>
              </el-table-column>
              <span v-for="(item, index) in checkedProps" :key="index">
                <el-table-column :label="item" v-if="item === '业务编号'" prop="business.codes" min-width="110"></el-table-column>
                <el-table-column :label="item" v-if="item === '扣水'" prop="deductWeightWater" min-width="140"></el-table-column>
                <el-table-column :label="item" v-if="item === '扣杂'" prop="deductWeightImpurity" min-width="140"></el-table-column>
                <el-table-column :label="item" v-if="item === '其他扣重'" prop="deductWeight" min-width="140"></el-table-column>
                <el-table-column :label="item" v-if="item === '路耗'" prop="lossWeight" min-width="140"></el-table-column>
                <el-table-column :label="item" v-if="item === '原发时间'" prop="originalDate" width="140"></el-table-column>
                <el-table-column :label="item" v-if="item === '磅单打印次数'" prop="weightListPrintTimes" width="140">
                  <template slot-scope="scope">
                      {{scope.row.weightListPrintTimes | noValue}}
                  </template>
                </el-table-column>
                <el-table-column prop="createBy.loginName" min-width="110px" :label="item" v-if="item ==='创建人'">
                    <template slot-scope="scope">
                        <span v-if="scope.row.createBy && scope.row.createBy.loginName">
                             {{scope.row.createBy.loginName | noValue}}
                        </span>
                        <span v-else>--</span>
                    </template>
                </el-table-column>
                <el-table-column prop="createDate" :label="item" width="140px" v-if="item==='创建时间'">
                  <template slot-scope="scope">
                      {{scope.row.createDate | noValue}}
                  </template>
                </el-table-column>
                <el-table-column prop="updateBy.loginName" min-width="120px" :label="item" v-if="item==='上次操作人'">
                    <template slot-scope="scope">
                        <span v-if="scope.row.updateBy && scope.row.updateBy.loginName">
                           {{scope.row.updateBy.loginName | noValue}}
                        </span>
                        <span v-else>--</span>
                    </template>
                </el-table-column>
                <el-table-column prop="updateDate" :label="item" width="140px" v-if="item==='上次操作时间'">
                    <template slot-scope="scope">
                        {{scope.row.updateDate | noValue}}
                    </template>
                </el-table-column>
              </span>
              <el-table-column label="操作" width="235">
                <template slot-scope="scope">
                  <el-dropdown @command="revokeCommand">
                    <span class="el-dropdown-link">撤销<i class="el-icon-arrow-down el-icon--right"></i></span>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item :command="{method:'revokeTareOperate', row:scope.row}">撤销皮重</el-dropdown-item>
                      <el-dropdown-item :command="{method:'revokeGrossOperate', row:scope.row}">撤销毛重</el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                  <el-dropdown @command="handleCommand">
                    <span class="el-dropdown-link">修改<i class="el-icon-arrow-down el-icon--right"></i></span>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item :command="{method:'updateOperate', row:scope.row}">修改过磅单</el-dropdown-item>
                      <el-dropdown-item :command="{method:'updTransport', row:scope.row}">修改派车单</el-dropdown-item>
                      <el-dropdown-item :command="{method:'modificatedRecord', row:scope.row}" v-if="hasPermission('weight:weightOperateDetail:list')">修改记录</el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                  <el-dropdown @command="moreCommand">
                    <span class="el-dropdown-link">更多<i class="el-icon-arrow-down el-icon--right"></i></span>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item :command="{method:'', row:scope.row}">打印磅单</el-dropdown-item>
                      <el-dropdown-item :command="{method:'', row:scope.row}">按业务打印磅单</el-dropdown-item>
                      <el-dropdown-item :command="{method:'', row:scope.row}">按重量打印磅单</el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                </template>
              </el-table-column>
            </el-table>
            <el-pagination
              background
              @size-change="handleSizeChange1"
              @current-change="handleCurrentChange1"
              :page-size="page1.pageSize"
              :current-page="page1.pageNo"
              layout="total,sizes,prev, pager, next, jumper"
              :total="page1.total"
            >
            </el-pagination>
          </div>
        </div>
      </el-tab-pane>
      <el-tab-pane label="异常处理记录" name="second" class="record">
        <div class="exception-header">
          <el-form class="adjustCondition" :inline="true" :model="exceptionQueryForm">
            <el-form-item label="处理时间:">
              <el-date-picker
                class="adjustDate"
                value-format="yyyy-MM-dd HH:mm:ss"
                v-model="exceptionDateInput"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始时间"
                end-placeholder="结束时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item class="exception-keyword" label="关键字:">
              <el-input v-model="exceptionQueryForm.keyword" placeholder="请输入过磅单编号/往来名称/业务编号查询"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" class="search-btn" @click="getExceptionList(
                  page2,
                  orderBy2.name,
                  orderBy2.method,
                  exceptionQueryForm.keyword,
                  exceptionDateInput
                )">查询</el-button>
              <el-button @click="resetException">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
        <div class="exception-table">
          <!--      <div class="exception-table-title">-->
          <!--        总共 <span>85</span> 个条过磅单，其中已完成 <span style="color: #1890FF">10</span>条，未完成 <span-->
          <!--        style="color: #FF3E3E">75</span>条-->
          <!--      </div>-->
          <div class="clear">
            <section class="right-but" style="display:flex;">
              <el-button type="text" style="margin-right:-13px;cursor:pointer;"
                         @click="refreshRecordList"
              >
                <img style="width:44px;height:36px;" src="~@/assets/img/shuaxin.png">
              </el-button>
              <PopoverBut ref="popoverButRecord" :checkedProps="checkedRecordProps" style="" :options="recordOptions"
                          @getCheckeds="handlerRecordCloumn"></PopoverBut>

            </section>
          </div>
          <div class="exception-table-content">
            <el-table
              v-loading="loading"
              :data="exceptionTableData"
              stripe
              border
              style="width: 100%">
              <el-table-column type="index" label="序号" width="70">
                <template slot-scope="scope">
          <span>{{
            (page2.pageNo - 1) * page2.pageSize + scope.$index + 1
          }}</span>
                </template>
              </el-table-column>
              <el-table-column label="过磅编号" prop="weight.weightCode" min-width="180">
                <template slot-scope="scope">
                  <el-link :underline="false" type="primary" @click="handleView(scope.row.operateType, scope.row)">
                    <p>{{$dictUtils.getDictLabel("processType", scope.row.business.processType, "")}}</p>
                    <p>{{scope.row.weight.weightCode}}</p>
                  </el-link>
                </template>
              </el-table-column>
              <el-table-column label="处理类型" prop="operateType" min-width="140">
                <template slot-scope="scope">
                  {{$dictUtils.getDictLabel("weightOperateType", scope.row.operateType, "")}}
                </template>
              </el-table-column>
              <el-table-column label="处理时间" prop="createDate" width="140"></el-table-column>

              <el-table-column label="往来名称" prop="business.companyName" min-width="200">
                <template slot-scope="scope">
                  <div>
                    <p v-if="scope.row.business && scope.row.business.companyName">{{scope.row.business.companyName | noValue}}</p>
                    <p v-else>--</p>
                  </div>
                  <div>
                    <p v-if="scope.row.product && scope.row.product.name">({{scope.row.product.name | noValue}})</p>
                    <p v-else>--</p>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="车牌号" prop="transport.truckNumber" min-width="120"></el-table-column>
<!--              <el-table-column label="货物" prop="product.name" min-width="140"></el-table-column>-->

              <el-table-column label="毛重时间" prop="gross.weightTime" width="140"></el-table-column>
              <el-table-column label="皮重时间" prop="tare.weightTime" width="140"></el-table-column>
<!--              <el-table-column label="过磅类型" prop="business.processType" min-width="110">-->
<!--                <template slot-scope="scope">-->
<!--                  {{$dictUtils.getDictLabel("processType", scope.row.business.processType, "")}}-->
<!--                </template>-->
<!--              </el-table-column>-->
              <el-table-column label="状态" prop="operateState" min-width="200">
<!--                <template slot-scope="scope">-->
<!--                  {{$dictUtils.getDictLabel("weightOperateState", scope.row.operateState, "")}}-->
<!--                </template>-->
                <template slot-scope="scope">
                  <div v-if="JSON.stringify(scope.row.flowState) === '{}'">
<!--                    <el-tag v-if="scope.row.operateState === -1" type="warning">{{-->
<!--                      $dictUtils.getDictLabel("weightOperateState", scope.row.operateState, "")-->
<!--                    }}</el-tag>-->
                    <div class="state empty" v-if="scope.row.operateState === 1 || scope.row.operateState === 101" type="info"><span></span>{{
                      $dictUtils.getDictLabel("weightOperateState", scope.row.operateState, "")
                    }}</div>
                    <div class="state process" v-if="scope.row.operateState === 2"><span></span>{{
                      $dictUtils.getDictLabel("weightOperateState", scope.row.operateState, "")
                    }}</div>
<!--                    <el-tag-->
<!--                      v-if="scope.row.operateState === 3 || scope.row.operateState === 4"-->
<!--                      type="danger"-->
<!--                    >{{ $dictUtils.getDictLabel("weightOperateState", scope.row.operateState, "") }}</el-tag-->
<!--                    >-->
                    <div class="state normal" v-if="scope.row.operateState === 100" type="success"><span></span>{{
                      $dictUtils.getDictLabel("weightOperateState", scope.row.operateState, "")
                    }}</div>
                  </div>
                  <div v-else>
                    <div class="state process"
                      v-if="
                        scope.row.flowState.code === 0 ||
                        scope.row.flowState.code === 3 ||
                        scope.row.flowState.code === 4 ||
                        scope.row.flowState.code === 5
                      "
                      type="danger"
                    ><span></span>{{ scope.row.flowState.status }}
                    </div>
                    <span v-if="scope.row.flowState.deleteReason"></span>
                    <div class="state process" v-if="scope.row.flowState.code === 2" type="primary"
                    ><span></span>{{ scope.row.flowState.status }} [{{
                        scope.row.flowState.currentTask.name
                      }}]
                    </div>
                    <div class="state process" v-if="scope.row.flowState.code === 100" type="success"><span></span>{{
                      scope.row.flowState.status
                    }}
                    </div>
                  </div>
                </template>
              </el-table-column>
              <!--              <el-table-column label="操作" width="130">-->
              <!--                <template slot-scope="scope">-->
              <!--                  <el-dropdown @command="handleCommandException">-->
              <!--                    <span class="el-dropdown-link">详情<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i></span>-->
              <!--                    <el-dropdown-menu slot="dropdown">-->
              <!--                      <el-dropdown-item :command="{method:'tareWeightReceivedView', row:scope.row}" v-if="scope.row.operateType ===1">撤销皮重</el-dropdown-item>-->
              <!--                      <el-dropdown-item :command="{method:'grossWeightReceivedView', row:scope.row}" v-if="scope.row.operateType ===2">撤销毛重</el-dropdown-item>-->
              <!--                      <el-dropdown-item :command="{method:'updateWeightView', row:scope.row}" v-if="scope.row.operateType ===3">修改磅单</el-dropdown-item>-->
              <!--                    </el-dropdown-menu>-->
              <!--                  </el-dropdown>-->
              <!--                </template>-->
              <!--              </el-table-column>-->
              <span v-for="(item, index) in checkedRecordProps" :key="index">
                 <el-table-column :label="item" v-if="item === '业务编号'" prop="business.codes" min-width="110">
                <template slot-scope="scope">
                  <span v-if="scope.row.business && scope.row.business.codes">{{scope.row.business.codes | noValue}}</span>
                  <span v-else>--</span>
                </template>
              </el-table-column>
                <el-table-column prop="createBy.loginName" min-width="110px" :label="item" v-if="item ==='创建人'">
              <template slot-scope="scope">
                  <span v-if="scope.row.createBy && scope.row.createBy.loginName">
                       {{scope.row.createBy.loginName | noValue}}
                  </span>
                  <span v-else>--</span>
              </template>
          </el-table-column>
          <el-table-column prop="createDate" :label="item" width="140px" v-if="item==='创建时间'">
            <template slot-scope="scope">
                {{scope.row.createDate | noValue}}
            </template>
        </el-table-column>
        <el-table-column prop="updateBy.loginName" min-width="120px" :label="item" v-if="item==='上次操作人'">
              <template slot-scope="scope">
                  <span v-if="scope.row.updateBy && scope.row.updateBy.loginName">
                     {{scope.row.updateBy.loginName | noValue}}
                  </span>
                  <span v-else>--</span>
              </template>
          </el-table-column>
          <el-table-column prop="updateDate" :label="item" width="140px" v-if="item==='上次操作时间'">
              <template slot-scope="scope">
                  {{scope.row.updateDate | noValue}}
              </template>
          </el-table-column>
              </span>

            </el-table>
            <el-pagination
              background
              @size-change="handleSizeChange2"
              @current-change="handleCurrentChange2"
              :page-size="page2.pageSize"
              :current-page="page2.pageNo"
              layout="total,sizes,prev, pager, next, jumper"
              :total="page2.total"
            >
            </el-pagination>
          </div>
        </div>
      </el-tab-pane>
    </el-tabs>
    <RecordForm ref="recordForm"></RecordForm>
    <Details ref="details"></Details>
    <UpdateForm ref="updateForm" @refreshDataList="refreshList"></UpdateForm>
    <UpdateTransport ref="updateTransport" @refreshDataList="refreshList"></UpdateTransport>
    <TaskForm :flowTitle="flowTitle" v-if="" :procInsId="procInsId" ref="TaskForm"></TaskForm>
    <receivedReason flowTitle="撤销原因" ref="receivedReason" @refreshDataList="refreshList"></receivedReason>
    <ViewTareForm ref="ViewTareForm"></ViewTareForm>
    <ViewGrossForm ref="ViewGrossForm"></ViewGrossForm>
    <ViewEditForm ref="ViewEditForm"></ViewEditForm>
  </div>
</template>

<script>
  import { getList, getExceptionList, tareWeightReceive, grossWeightReceive } from '@/api/weightingManagent/weight.js'
  import TaskForm from '@/components/flow/TaskForm'
  import RecordForm from './recordForm'
  import Details from './details'
  import UpdateForm from './updateForm'
  import UpdateTransport from './updateTransport'
  import receivedReason from './receivedReason'
  import PopoverBut from '@/components/button/popoverBut'
  import ViewTareForm from './viewTareForm'
  import ViewGrossForm from './viewGrossForm'
  import ViewEditForm from './viewEditForm'

  const options1 = []
  const options2 = []
  export default {
    components: {
      RecordForm,
      Details,
      UpdateForm,
      UpdateTransport,
      TaskForm,
      receivedReason,
      PopoverBut,
      ViewTareForm,
      ViewGrossForm,
      ViewEditForm
    },
    data () {
      return {
        loading: false,
        flowTitle: '',
        activeName: 'first',
        value1: [],
        input: '',
        dateInput: '',
        exceptionDateInput: '',
        procInsId: '',
        checked: true,
        tableData: [
        ],
        completedCount:0,
        noCompletedCount:0,
        totalCount:0,
        exceptionTableData: [],
        page1: {
          pageSize: 10,
          pageNo: 1,
          total: 0
        },
        page2: {
          pageSize: 10,
          pageNo: 1,
          total: 0
        },
        queryForm: {
          keyword: '',
          startTime: '',
          endTime: '',
          processType: '',
          transProps: ''
        },
        exceptionQueryForm: {
          keyword: '',
          startTime: '',
          endTime: ''
        },
        checkedProps: options1,
        checkedRecordProps: options2,
        options: [
          // {label: '业务编号', key: 'business.codes'},
          // {label: '扣水', key: 'deductWeightWater'},
          // {label: '扣杂', key: 'deductWeightImpurity'},
          // {label: '其他扣重', key: 'deductWeight'},
          // {label: '路耗', key: 'lossWeight'},
          // {label: '原发时间', key: 'originalDate'},
          // {label: '磅单打印次数', key: 'weightListPrintTimes'},
          // {label: '创建人', key: 'createBy.loginName'},
          // {label: '创建时间', key: 'createDate'},
          // {label: '上次操作人', key: 'updateBy.loginName'},
          // {label: '上次操作时间', key: 'updateDate'}
        ],
        recordOptions: [
          {label: '业务编号', key: 'business.codes'},
          {label: '创建人', key: 'createBy.loginName'},
          {label: '创建时间', key: 'createDate'},
          {label: '上次操作人', key: 'updateBy.loginName'},
          {label: '上次操作时间', key: 'updateDate'}
        ],
        orderBy: {
          name: 'create_date',
          method: 'desc'
        },
        orderBy2: {
          name: 'create_date',
          method: 'desc'
        },
        operateType:''
      }
    },
    methods: {
      refreshList () {
        this.getList(this.page1, this.orderBy, this.queryForm.keyword, this.dateInput, this.queryForm.transProps)
      },
      // 刷新异常处理记录
      refreshRecordList () {
        this.getExceptionList(
          this.page2,
          this.orderBy2.name,
          this.orderBy2.method,
          this.exceptionQueryForm.keyword,
          this.exceptionQueryForm.startTime,
          this.exceptionQueryForm.endTime
        )
      },
      // 是否显示某列数据
      handlerCloumn (e) {
        this.checkedProps = e
        // console.log(e)
      },
      // 是否显示异常处理记录某列数据
      handlerRecordCloumn (e) {
        this.checkedRecordProps = e
        // console.log(e)
      },
      viewDetail (row) {
        this.$refs.details.init('view', row)
      },
      reset () {
        this.queryForm.keyword = ''
        this.queryForm.startTime = ''
        this.queryForm.endTime = ''
        this.queryForm.processType = ''
        this.queryForm.transProps = ''
        this.dateInput = ''
      },
      resetException () {
        this.exceptionQueryForm.keyword = ''
        this.exceptionQueryForm.startTime = ''
        this.exceptionQueryForm.endTime = ''
        this.exceptionQueryForm.processType = ''
        this.exceptionDateInput = ''
      },
      handleClick (tab) {
        if (tab.index === '1') {
          this.getExceptionList(this.page2, '', '', '', '')
        }
        if (tab.index === '0') {
          this.getList(this.page1, this.orderBy, this.queryForm.keyword, this.dateInput, this.queryForm.transProps)
        }
      },
      handleSizeChange1 (e) {
        this.page1.pageSize=e;
        this.getList(this.page1, this.orderBy, this.queryForm.keyword, this.dateInput, this.queryForm.transProps)
      },
      handleCurrentChange1 (e) {
        this.page1.pageNo = e
        this.getList(this.page1, this.orderBy, this.queryForm.keyword, this.dateInput, this.queryForm.transProps)
      },
      handleSizeChange2 (e) {
        this.page2.pageSize = e
        this.getExceptionList(this.page2, '', '', '', '')
      },
      handleCurrentChange2 (e) {
        this.page2.pageNo = e
        this.getExceptionList(this.page2, '', '', '', '')
      },
      // 获取过磅流水
      getList (params, orderBy, keyword, date, transProps) {
        this.loading = true
        getList({
          pageSize: params.pageSize,
          pageNo: params.pageNo,
          orderBy: orderBy.name,
          orderByAORC: orderBy.method,
          keyword: keyword,
          startTime: date == null ? null : date[0],
          endTime: date == null ? null : date[1],
          transProps: transProps
        }).then(({data}) => {
          if (data.code === '200') {
            this.tableData = data.result.page.list
            this.page1.total = data.result.total.totalCount
            this.totalCount = data.result.total.totalCount
            this.completedCount = data.result.total.completedCount
            this.noCompletedCount = data.result.total.noCompletedCount
            this.loading = false
          }
        })
      },
      // 获取过磅异常记录
      getExceptionList (params, orderName, orderByAORC, keyword, date) {
        this.loading = true
        getExceptionList({
          pageSize: params.pageSize,
          pageNo: params.pageNo,
          orderBy: orderName,
          orderByAORC: orderByAORC,
          keyword: keyword,
          startTime: date == null ? null : date[0],
          endTime: date == null ? null : date[1]
        }).then(({data}) => {
          if (data.code === '200') {
            for (let i = 0; i < data.result.list.length; i++) {
              if (!data.result.list[i].flowState) {
                let flowState = {}
                this.$set(data.result.list[i], 'flowState', flowState)
              }
            }
            this.exceptionTableData = data.result.list
            this.page2.total = data.result.count
            this.loading = false
          }
        })
      },
      // 日期选择
      changeHandlerDate (e) {
        this.queryForm.startTime = e[0]
        this.queryForm.endTime = e[1]
      },
      changeHandlerDateException (e) {
        this.exceptionQueryForm.startTime = e[0]
        this.exceptionQueryForm.endTime = e[1]
      },
      modificatedRecord (trailId) {
        this.$refs.recordForm.init('send', trailId)
      },
      revokeTareOperate (row) {
        if (row.transport.transProps === 1 && row.transport.state === 10) {
          this.$message({
            message: '已过毛重，不支持撤销皮重',
            type: 'warning'
          })
        } else {
          this.$confirm('撤销后，本次皮重信息将失效，确定要撤销皮重吗？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消'
          }).then((res) => {
              this.$refs.receivedReason.init('edit', row.id, row.truckTrailId,row.transport.transProps,1)
          })
        }
      },
      revokeGrossOperate (row) {
        if (row.transport.transProps === 2 && row.transport.state === 20) {
          this.$message({
            message: '已过皮重，不支持撤销毛重',
            type: 'warning'
          })
        } else {
          this.$confirm('撤销后，本次毛重信息将失效，确定要撤销毛重吗？', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消'
          }).then((res) => {
              this.$refs.receivedReason.init('edit', row.id,row.truckTrailId,row.transport.transProps,2)
          })
        }
      },
      update (row) {
        this.$refs.updateForm.init('update', row)
      },
      updTransport (row) {
        this.$refs.updateTransport.init('update', row)
      },
      revokeCommand (command) {
        if (command.method === 'revokeTareOperate') {
          this.revokeTareOperate(command.row)
        } else if (command.method === 'revokeGrossOperate') {
          this.revokeGrossOperate(command.row)
        }
      },
      handleCommand (command) {
        if (command.method === 'updateOperate') {
          this.update(command.row)
        } else if (command.method === 'modificatedRecord') {
          this.modificatedRecord(command.row.truckTrailId)
        } else if (command.method === 'updTransport') {
          this.updTransport(command.row)
        }
      },
      moreCommand (command) {

      },
      tareWeightReceivedView (row) {
        if(row.procInsId==undefined || row.procInsId == ''){
          this.$refs.ViewTareForm.init('detail', row)
        }else{
          this.$refs.TaskForm.detailsVisible = true
          this.flowTitle = '皮重作废详情'
          this.procInsId = row.procInsId
        }
      },
      grossWeightReceivedView (row) {
        if(row.procInsId==undefined || row.procInsId == ''){
          this.$refs.ViewGrossForm.init('detail', row)
        }else{
          this.$refs.TaskForm.detailsVisible = true
          this.flowTitle = '毛重作废详情'
          this.procInsId = row.procInsId
        }
      },
      updateWeightView (row) {
        if(row.procInsId==undefined || row.procInsId == ''){
          this.$refs.ViewEditForm.init('detail', row)
        }else{
          this.$refs.TaskForm.detailsVisible = true
          this.flowTitle = '修改磅单详情'
          this.procInsId = row.procInsId
        }
      },
      handleView (operateType, row) {
        if (operateType === 1) {
          // this.handleCommandException({method: 'tareWeightReceivedView', row: row})
          this.tareWeightReceivedView(row)
        } else if (operateType === 2) {
          // this.handleCommandException({method: 'grossWeightReceivedView', row: row})
          this.grossWeightReceivedView(row)
        } else if (operateType === 3) {
          // this.handleCommandException({method: 'updateWeightView', row: row})
          this.updateWeightView(row)
        }
      },
      handleCommandException (command) {
        if (command.method === 'tareWeightReceivedView') {
          this.tareWeightReceivedView(command.row)
        } else if (command.method === 'grossWeightReceivedView') {
          this.grossWeightReceivedView(command.row)
        } else if (command.method === 'updateWeightView') {
          this.updateWeightView(command.row)
        }
      }
    },
    mounted () {
      this.getList(this.page1, this.orderBy, this.queryForm.keyword, this.dateInput, this.queryForm.transProps)
      this.$refs.popoverBut.disable = true
    }
  }
</script>

<style lang="scss" scoped>
@import '@/assets/scss/config.scss';
::v-deep.exception-handle {
      margin:-20px;
      >.el-tabs{
        .record{
          .clear{
            display: inherit;
          }
          .exception-header{
            .el-form-item{
              margin-bottom: 0;
            }
          }

          .el-table{
            td:last-child .cell{
              padding-right: 20px;
            }
          }
        }
        >.el-tabs__header{
          margin-bottom: 0;
          .el-tabs__item{
            width: 150px;
            height: 50px;
            line-height: 48px;
            border: 1px solid transparent;
            /*border-radius: 6px 0px 0px 0px;*/
            font-size: 16px;
            font-family: Microsoft YaHei;
            font-weight: 400;
            text-align: center;
            padding: 0;
          }
          .el-tabs__item.is-active{
            background: $--color-primary-liyu;
            border-color: #EEEEEE;
            color: #FFFFFF;
          }
          .el-tabs__active-bar{
            display: none;
          }
          .el-tabs__nav-wrap::after{
            height: 1px;
            background: #EEEEEE;
          }
        }
        >.el-tabs__content{
          padding: 20px;
        }
      }
    .exception-header {
      &.weight{
        .el-form{
          .adjust{
            display: inline-block;
            @media screen and (max-width: 1532px){
              display: block;
            }
          }
          .el-form-item{
            @media screen and (min-width: 1533px) and (max-width: 1630px){
              margin-right: 20px;
            }
            &:last-child{
              margin-right: 0;
            }
          }
        }
      }
      .el-form{

        .el-form-item{
          margin-right: 50px;
          margin-bottom: 20px;

        }
        .exception-keyword{
          input{
            width: 320px;
          }
        }
        .el-input.el-input--suffix{
          width: 175px;
        }
      }
    }
  .clear{
    display: flex;
    display: -webkit-flex;
    margin-bottom: 10px;
    &>div{
      flex: 1;
      color: #999999;
      font-size: 14px;
      align-self: flex-end;
    }
  }
  .clear:after{
    clear: both;
    content: '';
    display: table;
  }
    .exception-table {

      .el-table__row{
        td:not(:last-child){
          .el-link--inner{
            margin-right: 0 !important;
          }
          /*padding: 0;*/
          /*border-color: #dddddd;*/
        }
        .el-dropdown{
          margin-right: 16px;
          &:last-child{
            margin-right: 20px;
          }
        }
      }
      .adjustAppendTable.el-table{
        .row-more{
          .el-form-item{
            width: 30%;
            margin-right: 5%;
            &:last-child{
              margin-right: 0;
            }
          }
        }
      }
    }
  }
</style>
